from PyQt5.Qt import *

class MyQWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.setup_ui()

    def setup_ui(self):
        self.setWindowTitle("名称和属性")
        obj = QObject()
        # 对象名称
        obj.setObjectName("提示框")
        print(obj.objectName())
        # 对象属性
        obj.setProperty("k1", "v1")
        obj.setProperty("k2", "v2")
        print(obj.property("k1"))
        print(obj.dynamicPropertyNames())

# 测试
if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)
    window = MyQWidget()
    window.show()
    sys.exit(app.exec_())

"""
输出:
提示框
v1
[PyQt5.QtCore.QByteArray(b'k1'), PyQt5.QtCore.QByteArray(b'k2')]
"""